

	<div class="admin-biaogelist">
		<div class="listbiaoti am-cf">
			<ul class="am-icon-flag on"> 用户管理</ul>
			<dl class="am-icon-home" style="float: right;">当前位置： 首页 > <a href="#">用户管理</a></dl>
		</div>
		<div class="fbneirong">
			<div class="zuo" id="salerlist" style="line-height:21px;">所属销售：

               <select name="salerlist" >
                <?Php   foreach ($salerlist as $id=>$v){?>
                        <option  value="<?php  echo$v['id'];  ?>"><?php  echo$v['username'];  ?></option>
               <?php } ?>
                </select>

			</div>
			<div class="zuo" style="line-height:21px;">手机号：</div>
			<input type="text" name="phone">
			<input type="button" value="查找"   class="search am-btn am-btn-secondary am-radius " >
			<br />

				<table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped">
					<thead>
						<tr class="am-success">
                            <th class="table-check"><input type="checkbox" /></th>
                            <th class="table-type">用户ID</th>
							<th class="table-type">用户名</th>

							<th class="table-type">手机号</th>
							<th class="table-type" style="width: 80px;">账户余额</th>
							<th class="table-type" style="width: 80px;">金币余额</th>
							<th class="table-type">销售</th>
                            <th class="table-type">发布总单量</th>
							<th class="table-type" style="width: 100px;">总共消耗金额</th>
                            <th class="table-type" style="width: 100px;">总消耗金币</th>
                            <th class="table-type" style="width: 50px;">状态</th>
                            <th class="table-type" style="width: 50px;">会员</th>
							<th class="table-set" style="width:450px;">操作</th>
						</tr>

                    <tbody class="impowdith">
                    </tbody>
					</thead>
				</table>
              <div id="Pagination" style="margin:20px auto" style="display:none"></div>
		</div>
	</div>


</div>



<script>




   var salerlist=$("#salerlist").html();


    var on_request=false;
    var page=1;

  /*  <th class="table-type">用户名</th>
        <th class="table-type">用户密码</th>
        <th class="table-type">手机号</th>
        <th class="table-type">账户余额</th>
        <th class="table-type">金币余额</th>
        <th class="table-type">销售</th>
        <th class="table-type">最近发布任务时间</th>
        <th class="table-type">更改</th>
        <th class="table-set">操作</th>
*/

    $(".search").click(function () { page=1
        GetBusinessList();
    });

    /**
     * 分配销售
     */
    function  distribution() {
        $(".distribution").click(function () {
            var user_id=$(this).parents('tr').attr("user_id");

            layer.open({
                title: '分配用户销售',
                btn: '确认',
                area: ['500px', '200px'],
                content: ' <form action="" method="post" id="new-zf-psd">\n' +
                    '        <div>\n' +
                    '            <label for="">'+salerlist+'</label>\n' +
                    '        </div>\n' +
                    '        <div>\n' +
                    '        </div>\n' +
                    '    </form>',
                yes: function () {

                    var url = "<?php echo base_url(); ?>/Customer/distribution";
                    var salerid=$("#new-zf-psd").find("select[name='salerlist']").val();
                    var postdata = {
                        'salerid': salerid,
                        'user_id': user_id
                    };
                    on_request = true;
                    $.post(url, postdata, function (data) {
                        on_request = false;
                        if(data.code==0){
                            layer.msg("分配成功",{
                                time: 2000, //2s后自动关闭
                            });
                            // layer.close(layer.index);
                            GetBusinessList();
                        }else{
                            layer.msg(data.msg);
                        }

                    }, 'json');

                }
            });

        });


    }

    /**
     * 设置佣金
     */
    function  setcommission() {
        $(".setcommission").click(function () {
            var user_id=$(this).parents('tr').attr("user_id");

            var url = "<?php echo base_url(); ?>/Customer/getcommissionbyuser";
            var postdata = {
                'user_id': user_id
            };
            $.post(url, postdata, function (data) {
                layer.open({
                    title: '设置佣金',
                    btn: '确认',
                    area: ['500px', '300px'],
                    content: ' <form action="" method="post" id="new-zf-psd">\n' +
                        '        <div> 京东\n' +
                        '            <label for="">多少以内：</label><input type="number"   name="xiaoyu1000"  value="'+data.data[0]+'">\n' +
                        '        </div>\n' +
                        '        <div>\n' +
                        '            <label for="">收取费用：</label><input type="number"   name="xiaoyu5000"  value="'+data.data[1]+'" >\n' +
                        '        </div>\n' +
                        '        <div>\n' +
                        '            <label for="">且每增长：</label><input type="number" name="xiaoyu10000" value="'+data.data[2]+'" >\n' +
                        '        </div>\n' +
                        ' <div>\n' +
                        '            <label for="">收取金额：</label><input type="number" name="dayu10000" value="'+data.data[3]+'">\n' +
                        '        </div>'+
                        '        <div> 拼多多\n' +
                        '            <label for="">多少以内：</label><input type="number"   name="value1"  value="'+data.data[4]+'">\n' +
                        '        </div>\n' +
                        '        <div>\n' +
                        '            <label for="">收取费用：</label><input type="number"   name="value2"  value="'+data.data[5]+'" >\n' +
                        '        </div>\n' +
                        '        <div>\n' +
                        '            <label for="">且每增长：</label><input type="number" name="value3" value="'+data.data[6]+'" >\n' +
                        '        </div>\n' +
                        ' <div>\n' +
                        '            <label for="">收取金额：</label><input type="number" name="value4" value="'+data.data[7]+'">\n' +
                        '        </div>'+

                        '    </form>',
                    yes: function () {
                        var url = "<?php echo base_url(); ?>/Customer/setcommission";

                        var xiaoyu1000=$("input[name='xiaoyu1000']").val();
                        var xiaoyu5000=$("input[name='xiaoyu5000']").val();
                        var xiaoyu10000=$("input[name='xiaoyu10000']").val();
                        var dayu10000=$("input[name='dayu10000']").val();

                        var value1=$("input[name='value1']").val();
                        var value2=$("input[name='value2']").val();
                        var value3=$("input[name='value3']").val();
                        var value4=$("input[name='value4']").val();


                        var postdata = {
                            'jdvalue1': xiaoyu1000,
                            'jdvalue2': xiaoyu5000,
                            'jdvalue3': xiaoyu10000,
                            'jdvalue4': dayu10000,
                            'value1': value1,
                            'value2': value2,
                            'value3': value3,
                            'value4': value4,
                            'user_id': user_id
                        };
                        on_request = true;
                        $.post(url, postdata, function (data) {
                            on_request = false;
                            if(data.code==0){
                                layer.msg("设置佣金成功",{
                                    time: 2000, //2s后自动关闭
                                    /*   btn: ['明白了', '知道了', '哦']*/
                                });
                            }else{
                                layer.msg(data.msg);
                            }

                        }, 'json');

                    }
                });

            }, 'json');




        });

    }

    /**
     * 修改余额
     */
    function  changemoney() {
        $(".changemoney").click(function () {
            var user_id=$(this).parents('tr').attr("user_id");


            layer.open({
                title: '设置佣金',
                btn: '确认',
                area: ['500px', '200px'],
                content: ' <form action="" method="post" id="new-zf-psd">\n' +
                    '        <div>\n' +
                    '            <label for="">金额变动：</label><input type="text"   name="money" >\n' +
                    '        </div>\n' +
                    '        <div>\n' +
                    '            <label for="">金币变动：</label><input type="number"   name="gold" >\n' +
                    '        </div>\n' +
                    '    </form>',
                yes: function () {
                    var url = "<?php echo base_url(); ?>/Customer/Manualpay";

                    var money=$("input[name='money']").val();
                    var gold=$("input[name='gold']").val();

                    var postdata = {
                        'money': money,
                        'gold': gold,
                        'user_id': user_id
                    };
                    on_request = true;
                    $.post(url, postdata, function (data) {
                        on_request = false;
                        if(data.code==0){
                            layer.msg("修改资金成功",{
                                  time: 2000, //2s后自动关闭
                             /*   btn: ['明白了', '知道了', '哦']*/
                             });
                           // layer.close(layer.index);
                            GetBusinessList();
                        }else{
                            layer.msg(data.msg);
                        }

                    }, 'json');

                }
            });
        });

    }

    /**
     *禁用账户
     */
    function  stop() {
        $(".stop").click(function () {
            var user_id=$(this).parents('tr').attr("user_id");

            layer.confirm('确认变更该用户状态？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                var url = "<?php echo base_url(); ?>/Customer/stopuser";
                var postdata = {
                    'user_id': user_id
                };
                $.post(url, postdata, function (data) {
                    if(data.code==0){
                        layer.msg("修改状态成功",{
                            time: 2000, //2s后自动关闭
                            /*   btn: ['明白了', '知道了', '哦']*/
                        });
                        // layer.close(layer.index);
                        GetBusinessList();
                    }else{
                        layer.msg(data.msg);
                    }

                }, 'json');
            }, function(){

            });

        });
    }

   /**
    *设置和取消VIP
    */
   function  VIP() {
       $(".vip").click(function () {
           var user_id=$(this).parents('tr').attr("user_id");

           layer.confirm('确认变更该用户VIP状态？', {
               btn: ['确认','取消'] //按钮
           }, function(){
               var url = "<?php echo base_url(); ?>/Customer/setvip";
               var postdata = {
                   'user_id': user_id
               };
               $.post(url, postdata, function (data) {
                   if(data.code==0){
                       layer.msg("修改VIP状态成功",{
                           time: 2000, //2s后自动关闭
                           /*   btn: ['明白了', '知道了', '哦']*/
                       });
                       // layer.close(layer.index);
                       GetBusinessList();
                   }else{
                       layer.msg(data.msg);
                   }

               }, 'json');
           }, function(){

           });

       });
   }



   function setlisthtnml(data) {
        var html = "";
        if (data.list.length > 0) {
            $.each(data.list, function (key, value) {


                var butun="禁用";

                if(value.status!='正常'){
                    butun="解除";
                }



                if(value.VIP==0){
                    value.VIP="普通";
                }else{
                    value.VIP="VIP";
                }

                html = html +
                    '<tr user_id="'+value.id+'"><td><input type="checkbox" /></td>\n' +
                    '<td>' + value.id + '</td>\n' +
                    '<td>' + value.username + '</td>\n' +

                    '<td>' + value.phone + '</td>\n' +
                    '<td>' + value.money + '</td>\n' +
                    '<td>' + value.gold + '</td>\n' +
                    '<td>' + value.recommender + '</td>\n' +

                    '<td>' + value.task_nub + '</td>\n' +


                    '<td>' + value.allmoney + '</td>\n' +
                    '<td>' + value.allgold + '</td>\n' +
                    '<td>' + value.status + '</td>\n' +
                    '<td>' + value.VIP + '</td>\n' +
                    '<td >' +
                    '<span     class="am-btn am-btn-secondary am-radius vip" >VIP操作</span>\n' +
                    '<span     class="am-btn am-btn-secondary am-radius distribution" >分配</span>\n' +
                    '<span     class="am-btn am-btn-secondary am-radius setcommission">佣金</span>\n' +
                    '<span     class="am-btn am-btn-secondary am-radius changemoney">余额</span>\n' +
                    '<span     class="am-btn am-btn-secondary am-radius stop">'+butun+'</span></td>\n' +

                    '</tr>';
            });
            $(".impowdith").html(html);
            $('#Pagination').show();
            distribution();
            changemoney();
            setcommission();
            stop();
            VIP();
        } else {
            html += '<li><div style="width:100%;text-align:center;">&nbsp暂无数据</div></li>';
            $(".impowdith").html(html);
            $('#Pagination').hide();
        }
    }

    GetBusinessList();

    function GetBusinessList() {
        var url = "<?php echo base_url(); ?>/Customer/GetBusinessList";
        var phone=$("input[name='phone']").val();
        var date1=$("input[name='date1']").val();
        var date2=$("input[name='date2']").val();

        var postdata = {
            'page': page,
            'eapge': 15,
            'phone': phone

        };
        $.post(url, postdata, function (data) {
            on_request = false;
            setlisthtnml(data);
            setPagination("Pagination", data.count, page, data.epage, function (clickPage) {
                page = parseInt(clickPage) + 1;
                GetBusinessList();
            });
        }, 'json');

    }






</script>


    <div class="foods">
        <ul>
            版权所有@2015.
        </ul>
        <dl>
            <a href="" title="返回头部" class="am-icon-btn am-icon-arrow-up"></a>
        </dl>
    </div>




    </div>

    </div>




    </div>


    <!--<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>-->
    <script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
    <script src="<?php echo base_url() . 'public/business/'; ?>assets/js/polyfill/rem.min.js"></script>
    <script src="<?php echo base_url() . 'public/business/'; ?>assets/js/polyfill/respond.min.js"></script>
    <script src="<?php echo base_url() . 'public/business/'; ?>assets/js/amazeui.legacy.js"></script>


    <!--[if (gte IE 9)|!(IE)]><!-->
    <script src="<?php echo base_url() . 'public/business/'; ?>assets/js/amazeui.min.js"></script>
    <!--<![endif]-->



    </body>
    </html>